package cn.tedu.controller;

import cn.tedu.mapper.AddressMapper;
import cn.tedu.pojo.entity.Address;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Justin Parker
 * @author 2024/8/8 下午11:11
 * @version 1.0
 */
@RestController
@RequestMapping("/v1/address")
public class AddressController {

    @Autowired
    private AddressMapper addressMapper;

    @RequestMapping("insertAddress")
    public String insertAddress(Address address) {
      int i = addressMapper.insertAddress(address);
        return i > 0 ? "添加成功" : "添加失败";
    }

    @RequestMapping("selectAddress")
    public List<Address> selectAddress() {
        return addressMapper.selectAddress();
    }

    @RequestMapping("deleteAddress")
    public String deleteAddress(Integer id) {
        int i = addressMapper.deleteAddress(id);
        return i > 0 ? "删除成功" : "删除失败";
    }

    @RequestMapping("updateAddress")
    public String updateAddress(Address address) {
        int i = addressMapper.updateAddress(address);
        return i > 0 ? "修改成功" : "修改失败";
    }

}
